package com.nervenets.web.redis.domain.movie;

import com.nervenets.web.enumeration.MovieReleaseStatus;
import com.nervenets.web.enumeration.MovieStatus;
import com.nervenets.web.hibernate.domain.film.Movie;
import com.nervenets.web.redis.RedisSetDomain;
import lombok.Data;
import lombok.EqualsAndHashCode;

@EqualsAndHashCode(callSuper = true)
@Data
public class MovieStored extends RedisSetDomain {
    private long movieId;
    private String title;
    private String subtitle;
    private String coverImage;
    private MovieStatus status;
    private MovieReleaseStatus releaseStatus;
    private int userLimit;
    private long totalOfMoney;

    @Override
    public String getField() {
        return String.valueOf(movieId);
    }

    @Override
    public String getKey() {
        return String.format("MV_%s", String.format("%04d", movieId).substring(0, 4));
    }

    public MovieStored(long movieId) {
        this.movieId = movieId;
    }

    public MovieStored(Movie movie) {
        this.movieId = movie.getId();
        this.title = movie.getTitle();
        this.subtitle = movie.getInfo().getSubtitle();
        this.coverImage = movie.getCoverImage();
        this.status = movie.getStatus();
        this.releaseStatus = movie.getReleaseStatus();
        this.userLimit = movie.getUserLimit();
        this.totalOfMoney = movie.getTotalOfMoney();
    }
}
